<!--
 * @Author: hifishroom
 * @Date: 2021-08-23 12:48:16
 * @LastEditTime: 2021-09-04 13:07:29
 * @FilePath: \backstage\src\components\common\swiper\DateSlides.vue
-->
<template>
  <div class="date-slide-box">
    <h1 class="text-center date-slide-title">
      <em class="mr iconfont">&#xe69c;</em>风光展示
    </h1>
    <swiper class="swiper-container" :options="swiperOption" ref="mySwiper">
      <swiper-slide
        class="swiper-slide"
        v-for="(item, index) in itemList"
        :key="index"
      >
        <div class="a"><img class="date-slide-img" :src="item" alt="" /></div>
      </swiper-slide>
    </swiper>
  </div>
</template>

<script>
export default {
  name: "DateSlides",
  props: {
    itemList: {
      type: Array,
      default() {
        return [];
      }
    }
  },
  data() {
    return {
      listItem: {},
      swiperOption: {
        //设定初始化时slide的索引
        initialSlide: 0,
        loop: true,
        //自动播放
        freeMode: true,

        autoplay: {
          delay: 0,
          disableOnInteraction: false
        },
        slidesPerView: 4,
        // 设置轮播
        effect: "flip",
        //滑动速度
        speed: 3000,
        paginationClickable: true,

        //滑动之后回调函数
        on: {
          slideChangeTransitionEnd: function() {
            // console.log(this.activeIndex);//切换结束时，告诉我现在是第几个slide
          }
        }
      }
    };
  },
  computed: {
    swiper() {
      return this.$refs.mySwiper.$swiper;
    },
    list() {}
  },
  methods: {
    prev() {
      this.swiper.slidePrev();
    },
    next() {
      this.swiper.slideNext();
    }
  }
};
</script>

<style lang="scss">
.date-slide-box {
  margin: 20px 0;
}

.date-slide-title {
  font-size: 30px;
  margin-bottom: 20px;

  em {
    font-size: 30px;
  }
}
.a {
  display: flex;
  justify-content: center;
  align-items: center;
  width: 100%;
  height: 300px;

  background-color: antiquewhite;
}

.index-lot {
  width: 5vw;
  height: 1.5vh;
  margin-right: 5px;
  display: inline-block;
  border-radius: 5px;
  background: #000;
  opacity: 0.2;
  cursor: pointer;
}

.index-lot-active {
  background-color: #fff;
  opacity: 1;
}

.my-button-disabled {
  opacity: 0.2;
}

.swiper-container-free-mode > .swiper-wrapper {
  -webkit-transition-timing-function: linear; /*之前是ease-out*/
  -moz-transition-timing-function: linear;
  -ms-transition-timing-function: linear;
  -o-transition-timing-function: linear;
  transition-timing-function: linear;
  margin: 0 auto;
}

.date-slide-img {
  border-radius: 10px;
  margin: 0 5px;
  overflow: hidden;
  vertical-align: bottom;

  width: 100%;
  height: 96%;
}
</style>
